library(DendriticSpineR)

spines <- read_spines(file = "kolce dendrytyczne myszy tg3-gm.csv",
                      animal_col_name = "Animal",
                      group_col_name = "Group",
                      photo_col_name = "Photo_ID_rel",
                      spines_col_name = "spine_number",
                      properties_col_name = c("length", "area", "length_area_ratio", "length_width_ratio"),
                      header = TRUE, sep = ";")

length

plot_distributions(spines, property = "length", ecdf = TRUE, x_lim = c(0, 2))

plot_distributions(spines, property = "length", ecdf = FALSE, x_lim = c(0, 2))

plot_animals(spines, property = "length", box = FALSE)

plot_animals(spines, property = "length", box = TRUE)

plot_crossed_effects(spines, property = "length", strat = "Animal:group", mixed = TRUE)

(ms <- model_spines(spines, photo_col_name = "Photo_ID_rel"))
## $lsmeans
##  Group       lsmean         SE    df   lower.CL   upper.CL
##  tg dmso -0.2208147 0.02642542 14.22 -0.2774102 -0.1642192
##  tg gm   -0.3123998 0.02628428 14.06 -0.3687533 -0.2560464
##  wt dmso -0.3500326 0.02688921 14.71 -0.4074429 -0.2926222
##  wt gm   -0.3249601 0.02589163 13.06 -0.3808715 -0.2690487
## 
## Confidence level used: 0.95 
## 
## $contrasts
##  contrast             estimate         SE     df t.ratio p.value
##  tg dmso - tg gm    0.09158511 0.02667832 151.64   3.433  0.0042
##  tg dmso - wt dmso  0.12921784 0.03770056  14.47   3.427  0.0182
##  tg dmso - wt gm    0.10414537 0.03699567  13.63   2.815  0.0601
##  tg gm - wt dmso    0.03763273 0.03760177  14.39   1.001  0.7514
##  tg gm - wt gm      0.01256026 0.03689498  13.55   0.340  0.9858
##  wt dmso - wt gm   -0.02507247 0.02668953 159.47  -0.939  0.7837
## 
## P value adjustment: tukey method for comparing a family of 4 estimates
diffogram(ms)
## Warning: Removed 1 rows containing missing values (geom_segment).

area

plot_distributions(spines, property = "area", ecdf = TRUE, x_lim = c(0, 2))

plot_distributions(spines, property = "area", ecdf = FALSE, x_lim = c(0, 2))

plot_animals(spines, property = "area", box = FALSE)

plot_animals(spines, property = "area", box = TRUE)

plot_crossed_effects(spines, property = "area", strat = "Animal:group", mixed = TRUE)

(ms <- model_spines(spines, photo_col_name = "Photo_ID_rel"))
## $lsmeans
##  Group       lsmean         SE    df   lower.CL   upper.CL
##  tg dmso -0.2208147 0.02642542 14.22 -0.2774102 -0.1642192
##  tg gm   -0.3123998 0.02628428 14.06 -0.3687533 -0.2560464
##  wt dmso -0.3500326 0.02688921 14.71 -0.4074429 -0.2926222
##  wt gm   -0.3249601 0.02589163 13.06 -0.3808715 -0.2690487
## 
## Confidence level used: 0.95 
## 
## $contrasts
##  contrast             estimate         SE     df t.ratio p.value
##  tg dmso - tg gm    0.09158511 0.02667832 151.64   3.433  0.0042
##  tg dmso - wt dmso  0.12921784 0.03770056  14.47   3.427  0.0182
##  tg dmso - wt gm    0.10414537 0.03699567  13.63   2.815  0.0601
##  tg gm - wt dmso    0.03763273 0.03760177  14.39   1.001  0.7514
##  tg gm - wt gm      0.01256026 0.03689498  13.55   0.340  0.9858
##  wt dmso - wt gm   -0.02507247 0.02668953 159.47  -0.939  0.7837
## 
## P value adjustment: tukey method for comparing a family of 4 estimates
diffogram(ms)
## Warning: Removed 1 rows containing missing values (geom_segment).

length_area_ratio

plot_distributions(spines, property = "length_area_ratio", ecdf = TRUE, x_lim = c(0, 2))

plot_distributions(spines, property = "length_area_ratio", ecdf = FALSE, x_lim = c(0, 2))

plot_animals(spines, property = "length_area_ratio", box = FALSE)

plot_animals(spines, property = "length_area_ratio", box = TRUE)

plot_crossed_effects(spines, property = "length_area_ratio", strat = "Animal:group", mixed = TRUE)

(ms <- model_spines(spines, photo_col_name = "Photo_ID_rel"))
## $lsmeans
##  Group       lsmean         SE    df   lower.CL   upper.CL
##  tg dmso -0.2208147 0.02642542 14.22 -0.2774102 -0.1642192
##  tg gm   -0.3123998 0.02628428 14.06 -0.3687533 -0.2560464
##  wt dmso -0.3500326 0.02688921 14.71 -0.4074429 -0.2926222
##  wt gm   -0.3249601 0.02589163 13.06 -0.3808715 -0.2690487
## 
## Confidence level used: 0.95 
## 
## $contrasts
##  contrast             estimate         SE     df t.ratio p.value
##  tg dmso - tg gm    0.09158511 0.02667832 151.64   3.433  0.0042
##  tg dmso - wt dmso  0.12921784 0.03770056  14.47   3.427  0.0182
##  tg dmso - wt gm    0.10414537 0.03699567  13.63   2.815  0.0601
##  tg gm - wt dmso    0.03763273 0.03760177  14.39   1.001  0.7514
##  tg gm - wt gm      0.01256026 0.03689498  13.55   0.340  0.9858
##  wt dmso - wt gm   -0.02507247 0.02668953 159.47  -0.939  0.7837
## 
## P value adjustment: tukey method for comparing a family of 4 estimates
diffogram(ms)
## Warning: Removed 1 rows containing missing values (geom_segment).

length_width_ratio

plot_distributions(spines, property = "length_width_ratio", ecdf = TRUE, x_lim = c(0, 2))

plot_distributions(spines, property = "length_width_ratio", ecdf = FALSE, x_lim = c(0, 2))

plot_animals(spines, property = "length_width_ratio", box = FALSE)

plot_animals(spines, property = "length_width_ratio", box = TRUE)

plot_crossed_effects(spines, property = "length_width_ratio", strat = "Animal:group", mixed = TRUE)

(ms <- model_spines(spines, photo_col_name = "Photo_ID_rel"))
## $lsmeans
##  Group       lsmean         SE    df   lower.CL   upper.CL
##  tg dmso -0.2208147 0.02642542 14.22 -0.2774102 -0.1642192
##  tg gm   -0.3123998 0.02628428 14.06 -0.3687533 -0.2560464
##  wt dmso -0.3500326 0.02688921 14.71 -0.4074429 -0.2926222
##  wt gm   -0.3249601 0.02589163 13.06 -0.3808715 -0.2690487
## 
## Confidence level used: 0.95 
## 
## $contrasts
##  contrast             estimate         SE     df t.ratio p.value
##  tg dmso - tg gm    0.09158511 0.02667832 151.64   3.433  0.0042
##  tg dmso - wt dmso  0.12921784 0.03770056  14.47   3.427  0.0182
##  tg dmso - wt gm    0.10414537 0.03699567  13.63   2.815  0.0601
##  tg gm - wt dmso    0.03763273 0.03760177  14.39   1.001  0.7514
##  tg gm - wt gm      0.01256026 0.03689498  13.55   0.340  0.9858
##  wt dmso - wt gm   -0.02507247 0.02668953 159.47  -0.939  0.7837
## 
## P value adjustment: tukey method for comparing a family of 4 estimates
diffogram(ms)
## Warning: Removed 1 rows containing missing values (geom_segment).